<? //SELECT DISTINCT factuurregel.kwantiteit, factuurregel.idartikelen, artikelen.name, factuurregel.leverprijs FROM factuurregel, artikelen WHERE (idfactuur = '15') AND (artikelen.idartikelen = factuurregel.idartikelen)
session_start();
require_once('Local_Settings.php');
require_once('../cart/inc/functions/Cart_Functions.php');
if (!(isset($_SESSION['myusername']) && $_SESSION['mypassword'] != '')) {
header ("Location: http://www.group3productions.info/admin/main_login.php");
}
include 'config.php';
$name=$_SESSION['myusername'];
$result = mysql_query("SELECT admin FROM klant WHERE email = '{$name}'");
if (!$result) {
    die("1 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);
if($row['admin'] <> 1)
{
header ("Location: http://www.group3productions.info/index.php");
}
?>

<!--Alhier het systeem voor het behoud van een layout op de hele website. Alle wijzigingen aan de layout dienen te gebeuren in de header,body en footer.php bestanden. Enkel de content mag in dit bestand staan.-->
<?php include('../style/header-1.php');//hieronder komt de linkerbalk met artikelen ?>
<? include('../menu.php'); ?>
<?php include('../style/body-2.php');//hieronder het midden van de pagina ?>

<?php
//$table = 'factuurregel';
//$table2 = 'artikelen';
$name=$_GET['id'];

$result = mysql_query("SELECT DISTINCT factuurregel.kwantiteit, factuurregel.idartikelen, artikelen.name, factuurregel.leverprijs FROM factuurregel, artikelen WHERE (idfactuur = {$name}) AND (artikelen.idartikelen = factuurregel.idartikelen)");
if (!$result) {
    die("2 | Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);
$total = 0;

echo "<table border='1' align='center' cellspacing='0' bordercolordark='white' bordercolorlight='black'><tr>";

echo "<td><b>Qt.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Artikel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Prijs&nbsp;&nbsp;</b></td>";

echo "</tr>\n";

while($row = mysql_fetch_row($result))
{
	$idcode=$row[1];
	
	$row[2]=afkorten($row[2], 18);
	$total = ($total + $row[3]);
	
	//http://www.group3productions.info/artikelen.php?act=view&id=432041
	
    echo "<tr>";

    foreach($row as $cell)
        echo "<td><a href=\"http://www.group3productions.info/artikelen.php?act=view&id=$idcode\">$cell</a></td>";
    echo "</tr>\n";
}
mysql_free_result($result);
?>
<h3 style="text-align:center">Bestelling #<? echo $name; ?> specificatie</h3>
<?
echo "</table>";
echo "</br>";
echo "</br>";
echo "<form name=\"formupdate\" method=\"post\" action=\"order_modify.php?action=formupdate\">";
echo "<table border='1' align='center' cellspacing='0' bordercolordark='white' bordercolorlight='black'><tr>";
echo "</tr>\n";

echo "<tr><td>Totaalprijs:&nbsp;&nbsp;</td><td>$total&nbsp;&nbsp;</td></tr>\n";

$result = mysql_query("SELECT factuurdatum FROM factuur WHERE idfactuur = {$name}");
if (!$result) {
    die("3 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);
$geplaatst=$row['factuurdatum'];
echo "<tr><td>Geplaatst:&nbsp;&nbsp;</td><td>$geplaatst&nbsp;&nbsp;</td></tr>\n";

$result = mysql_query("SELECT betaald FROM factuur WHERE idfactuur = {$name}");
if (!$result) {
    die("3 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);
if($row['betaald'] == 0)
{
	echo "<tr><td>Betaald:&nbsp;&nbsp;</td>";
	echo "<td><p><select name=\"betaald\" size=\"1\"><option selected value=\"NEE\">NEE</option><option value=\"JA\">JA</option></select></p></td></tr>\n";
}
else
{
	echo "<tr><td>Betaald:&nbsp;&nbsp;</td>";
	echo "<td><p><select name=\"betaald\" size=\"1\"><option selected value=\"JA\">JA</option><option value=\"NEE\">NEE</option></select></p></td></tr>\n";
}

$result = mysql_query("SELECT verzonden FROM factuur WHERE idfactuur = {$name}");
if (!$result) {
    die("4 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);
if($row['verzonden'] == 0)
{
	echo "<tr><td>Verzonden:&nbsp;&nbsp;</td>";
	echo "<td><p><select name=\"verzonden\" size=\"1\"><option selected value=\"NEE\">NEE</option><option value=\"JA\">JA</option></select></p></td></tr>\n";
}
else
{
	echo "<tr><td>Verzonden:&nbsp;&nbsp;</td>";
	echo "<td><p><select name=\"verzonden\" size=\"1\"><option selected value=\"JA\">JA</option><option value=\"NEE\">NEE</option></select></p></td></tr>\n";
}

$result = mysql_query("SELECT datum_verzending FROM factuur WHERE idfactuur = {$name}");
if (!$result) {
    die("5 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);
if($row['datum_verzending'] == '0000-00-00')
{
	echo "<tr><td>Datum verzending:&nbsp;&nbsp;</td><td>N.V.T.&nbsp;&nbsp;</td></tr>\n";
}
else
{
	$datum = $row['datum_verzending'];
	echo "<tr><td>Datum verzending:&nbsp;&nbsp;</td><td>$datum&nbsp;&nbsp;</td></tr>\n";
}
echo "</table>";
echo "<input type=\"hidden\" name=\"id\" value=\"$name\"></br>";
echo "<p align=center><input type=\"submit\" name=\"versturen\" value=\"Bestelling updaten\"></p>";
echo "</form>";
?>

</br></br>


<?

$result = mysql_query("SELECT * FROM klant WHERE id = (SELECT idklant FROM factuur WHERE idfactuur = {$name})");
if (!$result) {
    die("6 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);

?>

</br>
<h3 style="text-align:center; text-decoration:underline">Personalia</h3>
</br><h4 style="text-align:center">
<? echo $row['voornaam']; ?>&nbsp;<? echo $row['tussenvoegsel']; ?>&nbsp;<? echo $row['achternaam']; ?><br><? echo $row['adres']; ?><br><? echo $row['postc']; ?>&nbsp;&nbsp; <? echo $row['woonplaats']; ?>
</br></br>
<? echo $row['telefoon']; ?>
</h4></p></br></br>

<form name="printform" target="_blank" method="post" action="print_order.php?id=<? echo $name; ?>">
<p align=center><input type="submit" name="afdrukken" value="Bestelling afdrukken"></p>
</form>


<?php include('../style/body-3.php');//hieronder de rechterbalk ?>
<? echo ( DisplayCartBald($Session_Prefix,$Currency_Symbol,$Currency_Code)); ?> 
<?php include('../style/footer-4.php');?>